'use client';
import React, { createContext, useContext } from 'react';

import { useTranslations } from 'next-intl';

const defaultTranslationContext = {
    _t: (key: string) => '',
};

const TranslationContext = createContext(defaultTranslationContext);

const useTranslation = () => {
    return useContext(TranslationContext);
};

const useTranslationContext = () => {
    return useContext(TranslationContext);
};

type TranslationProviderProps = {
    children: React.ReactNode;
};

const TranslationProvider = ({ children }: TranslationProviderProps) => {
    const t = useTranslations();

    return <TranslationContext.Provider value={{ _t: t }}>{children}</TranslationContext.Provider>;
};

export {
    //
    TranslationProvider,
    useTranslation,
    useTranslationContext,
};
